package com.gxjc.dao.bean;

import java.util.List;

import org.hibernate.Session;

import com.gxjc.model.Home;

public class HomeDao extends BaseDao {
	public List<Home> getAll() {
		String hql = "FROM Home";
		return getSession().createQuery(hql).list();
	}

	public void save(Home home) {
		//Session session = getSession();
		getSession().save(home);
		//session.getTransaction().commit();
		//session.close();
	}

	public void update(Home home) {
		//Session session = getSession();
		getSession().update(home);
		//session.getTransaction().commit();
		//session.close();
	}
	
	public void delete(int id) {
		getSession().delete(getSession().get(Home.class,id));
	}
	
	public Home getHomeById(int id) {
		return (Home)getSession().get(Home.class,id);
	}
	
	public List<Home> getHomeBySql(String hql) {
		return getSession().createQuery(hql).list();
	}
}
